package com.jwsoft.manager.core.gateway.controller;

import cn.hutool.core.convert.Convert;
import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.common.AreaControlVO;
import com.jwsoft.manager.common.vo.eduHouse.*;
import com.jwsoft.manager.common.vo.individuation.HouseInterfaceSaveVO;
import com.jwsoft.manager.core.integration.EduHouseIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 房产信息表网关
 *
 * @author wangtao
 * @since 2022-11-30
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "房产信息表", description = "房产信息表")
public class EduHouseController {

    @Autowired
    public EduHouseIntegration eduHouseIntegration;

    @Operation(summary = "房产信息表分页查询", description = "房产信息表分页查询")
    @PostMapping(value = "/eduHouse0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduHouseVO>> getList(@RequestBody @Validated EduHouseQueryVO vo) {
        return AppResponse.successData(eduHouseIntegration.getList(vo));
    }

    @Operation(summary = "房产信息表根据主键查询详情", description = "房产信息表根据主键查询详情")
    @PostMapping(value = "/eduHouse0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduHouseVO> getById(@RequestBody @Validated EduHouseKeyVO vo) {
        return AppResponse.successData(eduHouseIntegration.getById(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "房产信息表新增", description = "房产信息表新增")
    @PostMapping(value = "/eduHouse0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduHouseVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduHouseVO vo) {
        return AppResponse.successData(eduHouseIntegration.add(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "房产信息表修改", description = "房产信息表修改")
    @PostMapping(value = "/eduHouse0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduHouseVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduHouseVO vo) {
        return AppResponse.successData(eduHouseIntegration.edit(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "房产信息表删除", description = "房产信息表删除")
    @PostMapping(value = "/eduHouse0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduHouseKeyVO vo) {
        eduHouseIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "批量查询并保存三年内是否使用房产", description = "批量查询并保存三年内是否使用房产")
    @PostMapping(value = "/eduHouse0007", produces = "application/json;charset=UTF-8")
    public AppResponse getAndSaveBatchHouseUse(@RequestBody @Validated EduHouseQueryVO vo) {
        eduHouseIntegration.getAndSaveBatchHouseUse(vo);
        return AppResponse.successMsg("修改成功！");
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "批量审核房产", description = "批量审核房产")
    @PostMapping(value = "/eduHouse0008", produces = "application/json;charset=UTF-8")
    public AppResponse auditBatchHouse(@RequestBody @Validated HouseAuditReq req) {
        HouseAuditVO vo = Convert.convert(HouseAuditVO.class, req);
        eduHouseIntegration.auditBatchHouse(vo);
        return AppResponse.successMsg("审核成功！");
    }
    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "清除房产锁定过程缓存", description = "清除房产锁定过程缓存")
    @PostMapping(value = "/eduHouse0017", produces = "application/json;charset=UTF-8")
    public AppResponse clearUse(@RequestBody @Validated EduHouseQueryVO req) {
        eduHouseIntegration.clearUse(req);
        return AppResponse.successMsg("清除成功！");
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "批量改房产有效无效", description = "批量改房产有效无效")
    @PostMapping(value = "/eduHouse0009", produces = "application/json;charset=UTF-8")
    public AppResponse updateStatusBatchHouse(@RequestBody @Validated HouseUpdateStatusReq req) {
        HouseUpdateStatusVO vo = Convert.convert(HouseUpdateStatusVO.class, req);
        eduHouseIntegration.updateStatusBatchHouse(vo);
        return AppResponse.success();
    }

    @Operation(summary = "学生房产使用生成", description = "学生房产使用生成")
    @PostMapping(value = "/eduHouse0010", produces = "application/json;charset=UTF-8")
    public AppResponse initUseHouse(@RequestBody @Validated StudentHouseQueryReq req) {
        StudentHouseQueryVO vo = Convert.convert(StudentHouseQueryVO.class, req);
        eduHouseIntegration.initUseHouse(vo);
        return AppResponse.successMsg("生成成功！");
    }

    @Operation(summary = "根据预采集id房产接口信息获取并保存", description = "根据预采集id房产接口信息获取并保存")
    @PostMapping(value = "/eduHouse0011", produces = "application/json;charset=UTF-8")
    @Idempotent(expire = "PT2S") //2秒内防重复提交
    public AppResponse saveHouseByPre(@Validated @RequestBody EduHousePreVO vo) {
        eduHouseIntegration.saveHouseByPre(vo);
        return AppResponse.success();
    }

    @Operation(summary = "当年适龄子女我的房产", description = "当年适龄子女我的房产")
    @PostMapping(value = "/eduHouse0012", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduHouseVO>> getMyHouseInfo(@Validated @RequestBody AreaControlVO vo) {
        return AppResponse.successData(eduHouseIntegration.getMyHouseInfo(vo));
    }
    @Operation(summary = "金华当年适龄子女我的房产", description = "金华当年适龄子女我的房产")
    @PostMapping(value = "/eduHouseJh0012", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduHouseVO>> getMyHouseInfoJh(@Validated @RequestBody AreaControlVO vo) {
        return AppResponse.successData(eduHouseIntegration.getMyHouseInfoJh(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "大数据房产信息分页查询",description = "大数据户籍信息分页查询")
    @PostMapping(value = "/eduHouse0013", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduHouseVO>> queryBigDataHouseInterface(@RequestBody @Validated HouseInterfaceSaveVO vo) {
        return AppResponse.successData(eduHouseIntegration.queryBigDataHouseInterface(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "清除房产相关数据缓存",description = "清除房产相关数据缓存")
    @PostMapping(value = "/eduHouse0014", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduHouseVO>> queryBigDataHouseInterface(@RequestBody @Validated EduHouseKeyVO vo) {
        eduHouseIntegration.clearCache(vo);
        return AppResponse.successMsg("清除成功");
    }

    @Operation(summary = "特殊通道人员维护房产大数据获取", description = "特殊通道人员维护房产大数据获取")
    @PostMapping(value = "/eduHouse0015", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduHouseVO>> queryEnrollBeforeHouse(@RequestBody @Validated HouseInterfaceSaveVO vo) {
        return AppResponse.successData(eduHouseIntegration.queryEnrollBeforeHouse(vo));
    }

    @Operation(summary = "幼儿园房产大数据接口信息获取", description = "幼儿园房产大数据接口信息获取")
    @PostMapping(value = "/eduHouse0016", produces = "application/json;charset=UTF-8")
    @Idempotent(expire = "PT2S") //2秒内防重复提交
    public AppResponse saveHouseNurseryInterfaceData(@Validated @RequestBody HouseInterfaceSaveVO vo) {
        eduHouseIntegration.saveHouseNurseryInterfaceData(vo);
        return AppResponse.success();
    }

}
